home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / bossa.arc / BOSS_SUP.ARC / WN_FRMGE.C < prev    next >
C/C++ Source or Header  |  1990-03-12  |  10KB  |  245 lines

  1. /*
  2. ** The Window BOSS's Data Clerk
  3. ** Copyright (c) 1988 - Philip A. Mongelluzzo
  4. ** All rights reserved.
  5. **
  6. ** wn_frmget - Get (read) data entry form
  7. **
  8. ** Copyright (c) 1988 - Philip A. Mongelluzzo
  9. ** All rights reserved.
  10. **
  11. */
  12.  
  13. #include "windows.h"                    /* standard stuff */
  14.  
  15. #define ESC_CODE  -2                    /* return code: ESCAPE - ESC.001 */
  16.  
  17. /*
  18. *************
  19. * wn_frmget *
  20. *************
  21. */
  22.  
  23. /*
  24. ** wn_frmget(frm)
  25. **
  26. **    int     nfields - number of fields in form.
  27. **
  28. ** RETURNS:
  29. **
  30. **    TRUE  - indicating all fields of the form in question have been
  31. **            fetched and verified (where required).
  32. **
  33. **      or
  34. **
  35. **    Never Returns!!
  36. **
  37. ** NOTES:
  38. **
  39. **    This code can be used as is or can be customized to suite each
  40. **    applications need.  The section to customize is at the tail end
  41. **    of this file.  As distributed, logic diplays all prompts and
  42. **    display fields, positions to the first field, performs data
  43. **    entry on a field by field basis from the first to the last 
  44. **    (allowing editing along the way), asks for a confirmation to
  45. **    accept the fields on the form after the last field is entered,
  46. **    either accepts the form or drops into edit mode for all the
  47. **    fields on the form starting at the first field.
  48. **
  49. **    wn_frmget will not return until all data has been entered and
  50. **    verified (where required).
  51. **    
  52. **    This routine must be called after wn_frmopn, and before wn_frmcls.
  53. **
  54. */
  55.  
  56. /*
  57. *************
  58. * wn_frmget *
  59. *************
  60. */
  61.  
  62. #define FLD frm[indx]                   /* some shorthand */
  63.  
  64. wn_frmget(frm)                          /* input form processor */
  65. WIFORM frm;                             /* array of field pointers */
  66. {
  67. int indx;                               /* input field index */
  68. int rv;                                 /* wn_g???'s return value */
  69. int c;                                  /* scratch */
  70. WINDOWPTR wn;                           /* my OWN window */
  71.  
  72. static char *msg = "[Press ENTER to Accept, any other key to Edit]";
  73.  
  74.   wni_frmflg = TRUE;                    /* set initial state */
  75.                                         /* to display only */
  76.  
  77. begin:
  78.   indx = 0;                             /* reset index */
  79.   while(TRUE) {                         /* fetch input fields */
  80.     if(!FLD->fcode) break;              /* all done */
  81.     switch (FLD->fcode) {               /* based on function code */
  82.       case GDATE:
  83.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  84.           wns_ierr("wm_frmget@GDATE");
  85.         rv = wn_gdate(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  86.                       FLD->col, FLD->prmpt, 
  87.                       FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vip, 
  88.                       FLD->v3.vip, FLD->v4.vcp,
  89.                       FLD->v5.vcp,FLD->v6.vcp);
  90.         break;
  91.       case GTIME:
  92.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  93.           wns_ierr("wm_frmget@GTIME");
  94.         rv = wn_gtime(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  95.                       FLD->col, FLD->prmpt, 
  96.                       FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vip, 
  97.                       FLD->v3.vip, FLD->v4.vcp,
  98.                       FLD->v5.vcp,FLD->v6.vcp);
  99.         break;
  100.       case GINT:
  101.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  102.           wns_ierr("wm_frmget@GINT");
  103.         rv = wn_gint(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  104.                      FLD->col, FLD->prmpt, 
  105.                      FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vi, 
  106.                      FLD->v3.vi, FLD->v4.vi, FLD->v5.vcp,
  107.                      FLD->v6.vcp,FLD->v7.vcp);
  108.         break;
  109.       case GUINT:
  110.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  111.           wns_ierr("wm_frmget@GUINT");
  112.         rv = wn_guint(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  113.                       FLD->col, FLD->prmpt, 
  114.                       FLD->atrib, FLD->fill, FLD->v1.vuip, FLD->v2.vi, 
  115.                       FLD->v3.vui, FLD->v4.vui, FLD->v5.vcp,
  116.                       FLD->v6.vcp,FLD->v7.vcp);
  117.         break;
  118.       case GLONG:
  119.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  120.           wns_ierr("wm_frmget@GLONG");
  121.         rv = wn_glong(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  122.                       FLD->col, FLD->prmpt, 
  123.                       FLD->atrib, FLD->fill, FLD->v1.vlp, FLD->v2.vi, 
  124.                       FLD->v3.vl, FLD->v4.vl, FLD->v5.vcp,
  125.                       FLD->v6.vcp,FLD->v7.vcp);
  126.         break;
  127.       case GULONG:
  128.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  129.           wns_ierr("wm_frmget@GULONG");
  130.         rv = wn_gulong(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  131.                       FLD->col, FLD->prmpt, 
  132.                       FLD->atrib, FLD->fill, FLD->v1.vulp, FLD->v2.vi, 
  133.                       FLD->v3.vul, FLD->v4.vul, FLD->v5.vcp,
  134.                       FLD->v6.vcp,FLD->v7.vcp);
  135.         break;
  136.       case GFLOAT:
  137.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  138.           wns_ierr("wm_frmget@GFLOAT");
  139.         rv = wn_gfloat(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  140.                        FLD->col, FLD->prmpt, 
  141.                        FLD->atrib, FLD->fill, FLD->v1.vfp, FLD->v2.vi, 
  142.                        FLD->v3.vi, FLD->v4.vf, FLD->v5.vf, FLD->v6.vcp,
  143.                        FLD->v7.vcp,FLD->v8.vcp);
  144.         break;
  145.       case GDOUBL:
  146.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  147.           wns_ierr("wm_frmget@GDOUBL");
  148.         rv = wn_gdouble(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  149.                        FLD->col, FLD->prmpt, 
  150.                        FLD->atrib, FLD->fill, FLD->v1.vdp, FLD->v2.vi, 
  151.                        FLD->v3.vi, FLD->v4.vd, FLD->v5.vd, FLD->v6.vcp,
  152.                        FLD->v7.vcp,FLD->v8.vcp);
  153.         break;
  154.       case GPHONE:
  155.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  156.           wns_ierr("wm_frmget@GPHONE");
  157.         rv = wn_gphone(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  158.                        FLD->col, FLD->prmpt, 
  159.                        FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vip, 
  160.                        FLD->v3.vip, FLD->v4.vcp,
  161.                        FLD->v5.vcp,FLD->v6.vcp);
  162.         break;
  163.       case GTEXT:
  164.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  165.           wns_ierr("wm_frmget@GTEXT");
  166.         rv = wn_gtext(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  167.                       FLD->col, FLD->prmpt, 
  168.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vcp,
  169.                       FLD->v3.vcp,FLD->v4.vcp);
  170.         break;
  171.       case GUTEXT:
  172.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  173.           wns_ierr("wm_frmget@GUTEXT");
  174.         rv = wn_gutext(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  175.                       FLD->col, FLD->prmpt, 
  176.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vcp,
  177.                       FLD->v3.vcp,FLD->v4.vcp);
  178.         break;
  179.       case GLTEXT:
  180.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  181.           wns_ierr("wm_frmget@GLTEXT");
  182.         rv = wn_gltext(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  183.                       FLD->col, FLD->prmpt, 
  184.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vcp,
  185.                       FLD->v3.vcp,FLD->v4.vcp);
  186.         break;
  187.       case GBOOL:
  188.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  189.           wns_ierr("wm_frmget@GBOOL");
  190.         rv = wn_gbool(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  191.                       FLD->col, FLD->prmpt, 
  192.                       FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vcp,
  193.                       FLD->v3.vcp,FLD->v4.vcp);
  194.         break;
  195.       case DTEXT:                       /* display text */
  196.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  197.           wns_ierr("wm_frmget@DTEXT");
  198.         rv = wn_dtext(XEQ,NFRM,NFLD,FLD->wn, FLD->row, FLD->col, FLD->prmpt);
  199.         break;
  200.       case GPWORD:
  201.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  202.           wns_ierr("wm_frmget@GPWORD");
  203.         rv = wn_gpword(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  204.                       FLD->col, FLD->prmpt, 
  205.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vcp,
  206.                       FLD->v3.vcp,FLD->v4.vcp);
  207.         break;
  208.     }                                   /* end switch(frm.code) */
  209.     if(rv != BKTAB && rv != UARROW)     /* previous field ?? */
  210.       indx++;                           /* no, just bump index */
  211.     else {                              /* previous field request */
  212.       indx--;                           /* decrement index */
  213.       if(indx <= 0) indx = 0;           /* but dont be stupid! */
  214.     }
  215.     if(rv == ESC)                       /* Escape backout - ESC.001 */
  216.       return(ESC_CODE);                 /* Escape backout - ESC.001 */
  217.   }
  218.  
  219.   if(wni_frmflg) {                      /* first pass thru */
  220.     wni_frmflg = FALSE;                 /* displays prompts & data */
  221.     goto begin;                         /* now, lets *really* read */
  222.   }
  223.  
  224. /*************************************************************************
  225. *                                                                        *
  226. *                  CUSTOMIZE THE SECTION BELOW ONLY                      *
  227. *                                                                        *
  228. **************************************************************************/
  229.  
  230.                                         /* PRESS Return Stuff */
  231.   wn=wn_open(1000,(wni_mxrows-1),0,(int)strlen(msg),1,(RVIDEO),NVIDEO);
  232.   if(!wn) exit(1);
  233.   wn_puts(wn,0,0,msg);                  /* display message */
  234.   c = v_getch() & 0xff;                 /* fetch response */
  235.   wn_close(wn);                         /* make message go away */
  236.   if(c == CR)                           /* ENTER ?? */
  237.     return(TRUE);                       /* return if so */
  238.   if(c == ESC)                          /* Escape Backout - ESC.001 */
  239.     return(ESC_CODE);                   /* Escape Backout - ESC.001 */
  240.   else                                  /* else edit the */
  241.     goto begin;                         /* form ! */
  242. }     
  243.  
  244. /* End */
  245.